
#ifndef _GPIO_H_
#define _GPIO_H_
#include "stdint.h"
#include "hc32_ddl.h"
#include "hc32f460_gpio.h"


#define LED_PORT (PortA)
#define LED_PIN (Pin01)

static void SetLed(void)
{ 
	//PORT_SetBits(PortA,Pin01);
	*(uint16_t *)((uint32_t)(&M4_PORT->POSRA) + 0x10u * LED_PORT)|= LED_PIN;
}

static void ResetLed(void)
{
	//PORT_ResetBits(PortA,Pin01);
	*(uint16_t *)((uint32_t)(&M4_PORT->PODRA) + 0x10u * LED_PORT)&= (uint16_t)(~LED_PIN);
}

#define LED_H	SetLed()
#define LED_L	ResetLed()


#define CE_PORT (PortA)
#define CE_PIN (Pin15)
#define CSN_PORT (PortB)
#define CSN_PIN (Pin15)

#define CE_L PORT_ResetPortData(CE_PORT, CE_PIN) 	
#define CE_H PORT_SetPortData(CE_PORT, CE_PIN) 		
#define CSN_L PORT_ResetPortData(CSN_PORT, CSN_PIN) 
#define CSN_H PORT_SetPortData(CSN_PORT, CSN_PIN) 	

#define IRQ_PORT PortB
#define IRQ_PIN Pin10
#define READ_IRQ PORT_GetBit(IRQ_PORT, IRQ_PIN)

#define SHAKE_PORT PortA
#define SHAKE_PIN Pin03
#define READ_SHAKE PORT_GetBit(SHAKE_PORT, SHAKE_PIN)


void gpioSpiConfig(void);
void gpioLedConfig(void);
void gpioShakeConfig(void);

#endif

